﻿Imports System.Data.SqlClient
Imports System.Configuration
Public Class FmCapNhatHangHoa
    Dim Dt As New DataTable("HANGHOA")
   
    Private Sub FmCapNhatHangHoa_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        XdKetNoi()
        Dim dieuphoi As New SqlDataAdapter("Select * from HANGHOA", KetNoi)
        Dim DTKH As New DataTable
        dieuphoi.Fill(DTKH)
        KetNoi.Close()

        BindingSource1.DataSource = DTKH
        DgvHangHoa.DataSource = BindingSource1
        TxtTenHang.DataBindings.Add("Text", BindingSource1, "TENHANG")
        TxtDienGiai.DataBindings.Add("Text", BindingSource1, "DGIAI")
        TxtDVT.DataBindings.Add("Text", BindingSource1, "DVT")
        TxtMALoai.DataBindings.Add("Text", BindingSource1, "MALOAI")
        TxtTGBH.DataBindings.Add("Text", BindingSource1, "TGianBH")

        
        CbMAHANG.DataSource = DTKH
        'CbMAHANG.DisplayMember = "MAHANG"
        CbMAHANG.ValueMember = "MAHANG"
        CbMAHANG.DataBindings.Add("SelectedValue", BindingSource1, "MAHANG")


        KetNoi.Close()




    End Sub

    Dim ChuoiSoSanh As String = String.Empty

    Private Sub BtXem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtXem.Click
        XdKetNoi()
        Dim dieuphoi As New SqlDataAdapter("Select * from HANGHOA", KetNoi)

        Dim DTKH As New DataTable
        dieuphoi.Fill(DTKH)
        KetNoi.Close()
        DgvHangHoa.DataSource = DTKH

        DgvHangHoa.Columns(0).HeaderText = "Mã Hàng"
        'DgvHangHoa.Columns(2).Width = 250
        'DgvHangHoa.Columns(3).Width = 100
        'DgvHangHoa.Columns(4).Width = 60
        'DgvHangHoa.Columns(1).Width = 200
        DgvHangHoa.Columns(1).HeaderText = "Tên Hàng"
        DgvHangHoa.Columns(2).HeaderText = "Diễn Giải"
        DgvHangHoa.Columns(3).HeaderText = "Mã Loại"
        DgvHangHoa.Columns(4).HeaderText = "Đơn Vị Tính"
        DgvHangHoa.Columns(5).HeaderText = "Bảo Hành"
        KetNoi.Close()

    End Sub

    Private Sub BtThemMoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtThemMoi.Click
        FmNewHH.Show()

    End Sub

    'Private Sub CbMAHANG_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CbMAHANG.KeyDown

    '    Select Case e.KeyCode
    '        Case Keys.Enter
    '            Dim StrFilter As String = String.Format("MAHANG like '{0}%'", CbMAHANG.Text)
    '            Me.Text = String.Format("Found {0} Item(s)", +Dt.DefaultView.Count)

    '            Dt.DefaultView.RowFilter = StrFilter

    '    End Select
    'End Sub

    

    
    Private Sub BtThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtThoat.Click
        Me.Close()
    End Sub

    Private Sub BtIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtIn.Click
        FmDSHH.Show()
    End Sub
End Class